import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Test {
    public static void bubbleSort(int[] array){
        for(int i=0;i<array.length-1;i++){
            boolean flg=false;
            for(int j=0;j<array.length-1-i;j++){
                if(array[j]>array[j+1]){
                    int temp=array[j];
                    array[j]=array[j+1];
                    array[j+1]=temp;
                    flg=true;
                }
            }
            if(flg==false){
                return;
            }
        }
    }
    public static void main(String[] args) {
        //冒泡法
        int[] array={21,45,12,6,8,31};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));
        Test test=new Test();
        test.bubbleSort(array);
        System.out.println(Arrays.toString(array));

    }
    public static int[] func(int[] array){
        int[] ret=new int[array.length];
        for(int i=0;i<array.length;i++){
            ret[i]=array[i]*2;
        }
        return ret;
    }
    public static void main4(String[] args) {
        int num = 10;
        String str1 = num + "";
        String str2 = String.valueOf(num);
        System.out.println(str1);
        System.out.println(str2);
    }
//    public static int[] func(int[] array){
//        for(int i=0;i<array.length;i++){
//            array[i]=array[i]*2;
//        }
//        return array;
//    }
//    public static void main(String[] args) {
//        int []array={1,2,3,4,5};
//        int []temp=func(array);
//
//        System.out.println(Arrays.toString(temp));
//        System.out.println(Arrays.toString(array));
//    }
    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNextInt()){
            int n=scanner.nextInt();
            System.out.println(n);
        }
    }
    public static void main2(String[] args) {
        int []array={1,2,3,4,5};
        //方法一
        for(int i=0;i< array.length;i++){
            System.out.print(array[i]+" ");
        }
        System.out.println();
        //方法二
        for(int x:array){
            System.out.print(x+" ");//这个遍历方法不知道数组的下标
        }
        System.out.println();
        //方法三
        String ret=Arrays.toString(array);
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        System.out.println(Integer.MAX_VALUE);//2147483647
        System.out.println(Integer.MIN_VALUE);//-2147483648
        int a=10;
        long b=2147483648L;
        a=(int)b;
        System.out.println(a);

    }
}
